<?php
	#-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	Kumomado::load('Filter.KumomadoFilter');
    /**
     * @package libraries/filter/text/
     * @author Tsai, Min Che
	 * @version 1.0
     */
	class NoHTMLFilter implements KumomadoFilter {
		/**
		 * Convert special characters to HTML entities
		 * @param string $text String being converted
		 * @return string
		 */
		public function filter($text) {
			$quote_style = ENT_QUOTES;
			$charset = 'ISO-8859-1';
			$double_encode = true;
			if (version_compare(phpversion(), '5.2.3', '>=')) {
	            $text = htmlspecialchars($text, $quote_style, $charset, $double_encode);
	        } else {
	            $text = htmlspecialchars($text, $quote_style);
	        }
			return preg_replace(array('/&amp;/i', '/&nbsp;/i'), array('&', '&amp;nbsp;'), $text);
		}
	}
?>